static GSList *
sort_and_concat_results (ShellAppSystem *system,
- GSList *multiple_prefix_matches,
GSList *prefix_matches,
- GSList *multiple_substring_matches,
GSList *substring_matches)
{
- multiple_prefix_matches = g_slist_sort_with_data (multiple_prefix_matches,
- compare_apps_by_usage,
- system);
prefix_matches = g_slist_sort_with_data (prefix_matches,
compare_apps_by_usage,
system);
- multiple_substring_matches = g_slist_sort_with_data (multiple_substring_matches,
- compare_apps_by_usage,
- system);
substring_matches = g_slist_sort_with_data (substring_matches,
compare_apps_by_usage,
system);
- return g_slist_concat (multiple_prefix_matches, g_slist_concat (prefix_matches, g_slist_concat (multiple_substring_matches, substring_matches)));
+ return g_slist_concat (prefix_matches, substring_matches);
}
/**
GSList *terms,
GHashTable *apps)
{
- GSList *multiple_prefix_results = NULL;
GSList *prefix_results = NULL;
- GSList *multiple_subtring_results = NULL;
GSList *substring_results = NULL;
GSList *normalized_terms;
GHashTableIter iter;
ShellApp *app = value;
(void)id;
_shell_app_do_match (app, normalized_terms,
- &multiple_prefix_results, &prefix_results,
- &multiple_subtring_results, &substring_results);
+ &prefix_results,
+ &substring_results);
}
g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
g_slist_free (normalized_terms);
- return sort_and_concat_results (self, multiple_prefix_results, prefix_results,
- multiple_subtring_results, substring_results);
+ return sort_and_concat_results (self, prefix_results, substring_results);
}
GSList *terms)
{
GSList *iter;
- GSList *multiple_prefix_results = NULL;
GSList *prefix_results = NULL;
- GSList *multiple_substring_results = NULL;
GSList *substring_results = NULL;
GSList *normalized_terms = normalize_terms (terms);
ShellApp *app = iter->data;
_shell_app_do_match (app, normalized_terms,
- &multiple_prefix_results, &prefix_results,
- &multiple_substring_results, &substring_results);
+ &prefix_results,
+ &substring_results);
}
g_slist_foreach (normalized_terms, (GFunc)g_free, NULL);
g_slist_free (normalized_terms);
/* Note that a shorter term might have matched as a prefix, but
when extended only as a substring, so we have to redo the
sort rather than reusing the existing ordering */
- return sort_and_concat_results (system, multiple_prefix_results, prefix_results, multiple_substring_results, substring_results);
+ return sort_and_concat_results (system, prefix_results, substring_results);
}
/**
typedef enum {
MATCH_NONE,
MATCH_SUBSTRING, /* Not prefix, substring */
- MATCH_MULTIPLE_SUBSTRING, /* Matches multiple criteria with substrings */
MATCH_PREFIX, /* Strict prefix */
- MATCH_MULTIPLE_PREFIX, /* Matches multiple criteria, at least one prefix */
} ShellAppSearchMatch;
/* This is mainly a memory usage optimization - the user is going to
if (p != NULL)
{
if (p == app->casefolded_exec || *(p - 1) == '-')
- current_match = (current_match == MATCH_NONE) ? MATCH_PREFIX
- : MATCH_MULTIPLE_PREFIX;
+ current_match = MATCH_PREFIX;
else if (current_match < MATCH_PREFIX)
- current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
- : MATCH_MULTIPLE_SUBSTRING;
+ current_match = MATCH_SUBSTRING;
}
if (app->casefolded_description && current_match < MATCH_PREFIX)
*/
p = strstr (app->casefolded_description, term);
if (p != NULL)
- current_match = (current_match == MATCH_NONE) ? MATCH_SUBSTRING
- : MATCH_MULTIPLE_SUBSTRING;
+ current_match = MATCH_SUBSTRING;
}
if (current_match == MATCH_NONE)
void
_shell_app_do_match (ShellApp *app,
GSList *terms,
- GSList **multiple_prefix_results,
GSList **prefix_results,
- GSList **multiple_substring_results,
GSList **substring_results)
{
ShellAppSearchMatch match;
{
case MATCH_NONE:
break;
- case MATCH_MULTIPLE_PREFIX:
- *multiple_prefix_results = g_slist_prepend (*multiple_prefix_results, app);
- break;
case MATCH_PREFIX:
*prefix_results = g_slist_prepend (*prefix_results, app);
break;
- case MATCH_MULTIPLE_SUBSTRING:
- *multiple_substring_results = g_slist_prepend (*multiple_substring_results, app);
- break;
case MATCH_SUBSTRING:
*substring_results = g_slist_prepend (*substring_results, app);
break;